from appium.webdriver.common.mobileby import MobileBy
from appium.webdriver.webdriver import WebDriver
from faker import Faker

from test_appium.test_wechat.PO.PO_page.AddMember_Page import AddMember_Page
from test_appium.test_wechat.PO.PO_page.BasePage import BasePage


class addmember_menual_Page(BasePage):
    add_name_text = (MobileBy.XPATH,"//*[@resource-id='com.tencent.wework:id/bd6'and@text='必填']")
    add_phone_text = (MobileBy.XPATH,"//*[@resource-id='com.tencent.wework:id/g9e'and@text='必填']")
    save_btn = (MobileBy.XPATH,"//*[@resource-id='com.tencent.wework:id/alq'and@text='保存']")

    def edit_new_member(self):
        fake = Faker("zh_CN")
        name = fake.name()
        phone_number = fake.phone_number()
        #输入姓名
        #输入手机号
        """
        :return:
        """
       # add_name_text = self.driver.find_element_by_xpath("//*[@resource-id='com.tencent.wework:id/bd6'and@text='必填']")
       # add_name_text.send_keys(name)
       # add_phone_text = self.driver.find_element_by_xpath("//*[@resource-id='com.tencent.wework:id/g9e'and@text='必填']")
       # add_phone_text.send_keys(phone_number)
        #编辑姓名和手机号
        #save_btn = self.driver.find_element_by_xpath("//*[@resource-id='com.tencent.wework:id/alq'and@text='保存']")
       # save_btn.click()
        #点击保存
        self.find_and_sendkey(*self.add_name_text,name)
        self.find_and_sendkey(*self.add_phone_text,phone_number)
        self.find_and_click(*self.save_btn)
       # self.find_and_click(add_name_text)
        return AddMember_Page(self.driver)